#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	char *dest;
	int fd;
	int i;
	if (argv[argc-1][0] == '>' ) {
		dest = strtok (argv[argc-1], ">");	
		fd = open(dest, O_WRONLY|O_TURNC|O_CREAT);
		dup2(fd, 1);
		close(fd);
	}
	for (i = 1; i < argc; ++i) {
		write(1, argv[i], strlen(argv[i]));
		write(1, " ", 1);
	}
	write(1, "\n", 2);
	return 0;	
}
